package com.ddd.domain.user.entity;

import com.ddd.infrastructure.utils.JacksonUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
//@Builder  不要使用@Builder 因为继承会报错
//用户
public class UserDo {
    private Integer id;  //主键
    protected String userId; //用户的编号(雪花id)(外键关联ID)
    protected String name;
    private String pass;
    protected Integer age;
    private String sex;
    private String address;
    private String phone;



    public void setPass(String pass) {
        //1.限制密码必须是大于6位必须是英文和数字混合的

        //2. 验证完毕后加密密码为MD传入pass中
        this.pass = pass;
    }


    public Integer getAge() {

        return age;
    }

    public void setAge(Integer age) {

        //限制年龄在0~100
        this.age = age;
    }

    @Override
    public String toString() {
        return JacksonUtil.toJson(this);
    }

}
